import http from '../utils/http'
import store from '../store'


export function getGoodsList(){
  return http.get('/product/list').then(data=>{
    console.log(data)
    data = Object.freeze(data)
    if(data.code == 0){
      store.commit('initGoodsList',data.data)
    }
    return data
  })
}

export function getGoodsInfo(id){
  return http.get('/product/info',{id:id})
}

export function addCart(option){
  return http.post('/cart/add',option)
}
export function initCart(){
  return http.get('/cart/list')
}